from jinja2 import Template
import datetime
import config


def generate_report(data, report_name=str(datetime.datetime.now().date())):
    path = config.report_path
    if path[-1] != '/':
        path += '/' + report_name
    else:
        path += report_name
    file = open('report/template.html', 'r', encoding='utf8')
    template = Template(file.read())
    report = open(path + '.html', 'w', encoding='utf8')
    report.write(template.render(data=data))
    file.close()
    report.close()
    return path
